

/*
* Copyright @ 2017 com.iflysse.trains
* crm 下午1:42:55
* All right reserved.
*
*/
	
package com.qf.service.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import com.qf.dao.CrmStaffDao;
import com.qf.dto.CrmStaffDto;
import com.qf.pojo.CrmStaff;
import com.qf.service.CrmStaffService;
import com.qf.utils.DateUtil;

/**
* @desc: crm
* @descripe:XXXX
* @author: 周锐
* @createTime: 2017年7月25日 下午1:42:55
* @history:
* @version: v1.0

*/

public class CrmStaffServiceImpl implements CrmStaffService {

	private CrmStaffDao sd;
	
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmStaffService#addStaff(com.qf.pojo.CrmStaff)
	*/
		
	
	/**
	* @param sd the sd to set
	*/
	
	public void setSd(CrmStaffDao sd) {
	
		this.sd = sd;
	}


	@Override
	public void addStaff(CrmStaff staff) {
		
		sd.addStaff(staff);
			
	}

	
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmStaffService#updateStaff(com.qf.pojo.CrmStaff)
	*/
		
	@Override
	public void updateStaff(CrmStaff staff) {
		
		sd.updateStaff(staff);
			
	}

	
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmStaffService#crmstaffs()
	*/
		
	@Override
	public List<CrmStaffDto> findAllcrmstaffs() {
		List<CrmStaff> list = sd.findAllcrmstaffs();
		List<CrmStaffDto> staffs=new ArrayList<>();
		for(CrmStaff crmStaff:list){
			CrmStaffDto staff=new CrmStaffDto();
			staff.setStaffId(crmStaff.getStaffId());
			staff.setLoginName(crmStaff.getLoginName());
			staff.setLoginPwd(crmStaff.getLoginName());
			staff.setStaffName(crmStaff.getStaffName());
			staff.setGender(crmStaff.getGender());
			staff.setOnDutyDate(DateUtil.tranfaceString(crmStaff.getOnDutyDate()));
			staff.setDepName(crmStaff.getCrmPost().getCrmDepartment().getDepName());
			staff.setPostName(crmStaff.getCrmPost().getPostName());
			staffs.add(staff);
		}
		return staffs;	
	}


	
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmStaffService#findbyId(java.lang.Long)
	*/
		
	@Override
	public CrmStaff findbyId(Long staffId) {
		
		//TODO
		return sd.findbyId(staffId);
			
	}


	
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmStaffService#findStaff(java.lang.String)
	*/
		
	@Override
	public List<CrmStaffDto> findStaff(String staffName) {
		
		//TODO
		List<CrmStaff> list = sd.findStaff(staffName);
		List<CrmStaffDto> staffs=new ArrayList<>();
		for(CrmStaff crmStaff:list){
			CrmStaffDto staff=new CrmStaffDto();
			staff.setStaffId(crmStaff.getStaffId());
			staff.setLoginName(crmStaff.getLoginName());
			staff.setLoginPwd(crmStaff.getLoginName());
			staff.setStaffName(crmStaff.getStaffName());
			staff.setGender(crmStaff.getGender());
			staff.setOnDutyDate(DateUtil.tranfaceString(crmStaff.getOnDutyDate()));
			staff.setDepName(crmStaff.getCrmPost().getCrmDepartment().getDepName());
			staff.setPostName(crmStaff.getCrmPost().getPostName());
			staffs.add(staff);
		}
		return staffs;	
	}


	
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmStaffService#findByName(java.lang.String)
	*/
		
	@Override
	public CrmStaff findByName(String loginName) {
		
		//TODO
		return sd.findByName(loginName);
			
	}
			
	}



	